<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      height: 999px;
    }

    .box {
      position: absolute;
      left: 20%;
      top: 0;
      margin: 200px 0;
      width: 500px;
      height: 300px;
    }

    img {
      width: 500px;
      height: 300px;
    }

    .red-img {
      position: absolute;
      left: 0;
      top: 0;
      height: 0;
      width: 100%;
      overflow: hidden;
    }
  </style>
</head>

<body>
  <div class="box">
    <img src="../images/theme-index-blue.png" alt="">
    <div class="red-img">
      <img src="../images/theme-index-red.png" alt="">
    </div>
  </div>

  <script>

    const red_img = document.querySelector('.red-img')

    function getScrollTop() {
      var scrollTop = 0;
      if (document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop;
      } else if (document.body) {
        scrollTop = document.body.scrollTop;
      }
      return scrollTop;
    }

    setInterval(function () {
      console.log(getScrollTop())
      red_img.style.height = getScrollTop() * 5 + 'px'
    }, 30);




  </script>
</body>

</html>